<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>收支记录管理</title>
	<meta name="decorator" content="default"/>
	<link href="${ctxStatic}/jquery-select2/3.4/select2.min.css" rel="stylesheet" />
	<script src="https://select2.github.io/vendor/js/jquery.min.js"></script>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"></script>
	<script src="${ctxStatic}/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
	<script type="text/javascript">
		$(document).ready(function() {
			$(".js-example-basic-single").select2();
		});
		function page(n,s){
			$("#bankinfo").hide();
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		
		function excel(){
			$("#bankinfo").hide();
			$('#searchForm').attr('action',"${ctx}/jiujiu/jiuBalancePaymentsLog/excel");
			$('#searchForm').submit();
		}
		function search(){
			$("#bankinfo").hide();
			$('#searchForm').attr('action',"${ctx}/jiujiu/jiuBalancePaymentsLog");
			$('#searchForm').submit();
		}
		
		function queryBank(){
			var storeId = $("#storeId").val();
			if(storeId == ""){
				alert("请选择门店");
			}else{
				$.ajax({
					type: 'POST',
					url: "${ctx }/jiujiu/jiuStore/queryBank",
					dataType: "json",
					cache:true,
					async:false,
					data: {storeId:storeId},
					success: function (data) {
						if(data.result){
							$("#bankinfo").show();
							$("#tiRealName").html(data.tiRealName);
							$("#openingBank").html(data.openingBank);
							$("#bankCardNumber").html(data.bankCardNumber);
						}else{
							alert(data.msg);
						}
					}
				});
			}
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/jiujiu/jiuBalancePaymentsLog?manufactorId=${jiuBalancePaymentsLog.manufactorId}&storeId=${jiuBalancePaymentsLog.storeId}">收支记录列表</a></li>
		<shiro:hasPermission name="jiujiu:jiuBalancePaymentsLog:edit"><li><a href="${ctx}/jiujiu/jiuBalancePaymentsLog/form">收支记录添加</a></li></shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="jiuBalancePaymentsLog" action="${ctx}/jiujiu/jiuBalancePaymentsLog/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<label>门店名称 ：</label>
		<form:select path="storeId" class="js-example-basic-single">
			<form:option value="">全部</form:option>
			<c:forEach items="${JiuStoreList}" var="jiuStore">
                   <form:option value="${jiuStore.id}">${jiuStore.name}</form:option>
			</c:forEach>
       	</form:select>
       	
       	<label>类型：</label>
          <form:select path="type"   style="WIDTH: 130px">
                     <form:option value="">全部</form:option>
                         <form:option value="1">充值</form:option>
                         <form:option value="2">撤单</form:option>
                         <form:option value="3">结算</form:option>
                         <form:option value="4">下单</form:option>
                         <form:option value="5">提现</form:option>
                         <form:option value="6">反审</form:option>
         </form:select>
       	
       	<label>创建时间 ：</label>
			<input id="startTime" name="startTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
					value="<fmt:formatDate value="${jiuBalancePaymentsLog.startTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/> -至-
					
			<input id="endTime" name="endTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
					value="<fmt:formatDate value="${jiuBalancePaymentsLog.endTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/> 
		&nbsp;<input id="btnSubmit" class="btn btn-primary" type="button" value="查询" onclick="javascript:search()"/>
		&nbsp;<input class="btn btn-primary" type="button" value="导出" onclick="javascript:excel()"/>
		&nbsp;<input id="btnSubmit" class="btn btn-primary" type="button" value="查看门店开户行" onclick="javascript:queryBank()"/>
	</form:form>
	<c:if test="${not empty jiuStore}">
		<h1>门店剩余积分：${jiuStore.point}</h1>
    </c:if>
	
	<tags:message content="${message}"/>
	<div class="breadcrumb form-search" id="bankinfo" style="display:none;">
		提现账户姓名:<span id="tiRealName"></span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;开户行:<span id="openingBank"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;银行卡号:<span id="bankCardNumber"></span>
	</div>
	<table id="contentTable" class="table table-striped table-bordered ">
		<thead><tr>
		<th>订单号</th>
		<th>门店名称</th>
		<th>类型</th>
		<th>积分</th>
		<th>当前积分</th>
		<th>创建时间</th>
		<shiro:hasPermission name="jiujiu:jiuBalancePaymentsLog:edit"><th>操作</th></shiro:hasPermission></tr></thead>
		<tbody>
		<c:forEach items="${page.list}" var="jiuBalancePaymentsLog">
			<tr>
				<td>${jiuBalancePaymentsLog.orderNo}</td>
				<td>${jiuBalancePaymentsLog.storeName}</td>
				
					<c:choose>
					    <c:when test="${jiuBalancePaymentsLog.type eq 1}">
					      	<td> <h3><a href="${ctx}/jiujiu/jiuRechargeLog?id=${jiuBalancePaymentsLog.rechargeLogId}">充值<a></h3></td>
					      	
					      	<td>+${jiuBalancePaymentsLog.point}</td>
					      	
					    </c:when>
					     <c:when test="${jiuBalancePaymentsLog.type eq 2}">
					       <td><h3><a href="${ctx}/jiujiu/jiuOrder?orderNo=${jiuBalancePaymentsLog.orderNo}">撤单</a></h3></td>
					       <td>+${jiuBalancePaymentsLog.point}</td>
					    </c:when>
					     <c:when test="${jiuBalancePaymentsLog.type eq 3}">
					      	<td><h3><a href="${ctx}/jiujiu/jiuOrder?orderNo=${jiuBalancePaymentsLog.orderNo}"> 结算</a></h3></td>
					      	<td>+${jiuBalancePaymentsLog.point}</td>
					    </c:when>
					     <c:when test="${jiuBalancePaymentsLog.type eq 4}">
					       <td>	<h3><a href="${ctx}/jiujiu/jiuOrder?orderNo=${jiuBalancePaymentsLog.orderNo}">下单</a></h3></td>
					       <td>-${jiuBalancePaymentsLog.point}</td>
					    </c:when>
					     <c:when test="${jiuBalancePaymentsLog.type eq 5}">
					      	 <td> <h3><a href="${ctx}/jiujiu/jiuWithdrawalsLog?orderNo=${jiuBalancePaymentsLog.orderNo}">提现</a></h3></td>
					      	 <td>-${jiuBalancePaymentsLog.point}</td>
					    </c:when>
					     <c:when test="${jiuBalancePaymentsLog.type eq 6}">
					     	<td> <h3><a href="${ctx}/jiujiu/jiuOrder?orderNo=${jiuBalancePaymentsLog.orderNo}">反审</a></h3></td>
					     	 <td>-${jiuBalancePaymentsLog.point}</td>
					    </c:when>
					     <c:when test="${jiuBalancePaymentsLog.type eq 7}">
					     	<td> <h3><a href="${ctx}/jiujiu/jiuWithdrawalsLog?orderNo=${jiuBalancePaymentsLog.orderNo}">提现作废</a></h3></td>
					     	 <td>+${jiuBalancePaymentsLog.point}</td>
					    </c:when>
					     <c:when test="${jiuBalancePaymentsLog.type eq 8}">
					     	<td> <h3><a href="${ctx}/jiujiu/jiuRechargeLog?orderNo=${jiuBalancePaymentsLog.orderNo}">充值订单修改</a></h3></td>
					     	 <td>-${jiuBalancePaymentsLog.point}</td>
					    </c:when>
					     <c:when test="${jiuBalancePaymentsLog.type eq 9}">
					     	<td> <h3><a href="${ctx}/jiujiu/jiuRechargeLog?orderNo=${jiuBalancePaymentsLog.orderNo}">充值订单修改</a></h3></td>
					     	 <td>+${jiuBalancePaymentsLog.point}</td>
					    </c:when>
					    <c:otherwise>
					    </c:otherwise>
					</c:choose>
					
				<th>${jiuBalancePaymentsLog.nowPoint}</th>
				<td><fmt:formatDate value="${jiuBalancePaymentsLog.createTime}" type="both" pattern="yyyy-MM-dd HH:mm:ss" /> </td>
				<shiro:hasPermission name="jiujiu:jiuBalancePaymentsLog:edit"><td>
    				<a class="btn btn-success" href="${ctx}/jiujiu/jiuBalancePaymentsLog/form?id=${jiuBalancePaymentsLog.id}">修改</a>
					<a class="btn btn-danger" href="${ctx}/jiujiu/jiuBalancePaymentsLog/delete?id=${jiuBalancePaymentsLog.id}" onclick="return confirmx('确认要删除该收支记录吗？', this.href)">删除</a>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>
